<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/util.tld" prefix="myutil" %>
<!DOCTYPE HTML>
<html>
  <head>
    <title>商品管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link href = "/ecp/resources/css/default/base.css" rel = "stylesheet" type = "text/css"/>
	<link href = "/ecp/resources/css/uploadify.css" rel = "stylesheet" type = "text/css"/>
	
    <script type="text/javascript" src="/ecp/resources/js/jquery-1.8.1.js"></script>
    <script type="text/javascript" src="/ecp/resources/js/tydic.js"></script>
    <script type="text/javascript" src="/ecp/resources/js/jquery.uploadify.min.js"></script>
    <script type = "text/javascript">
         jQuery(function($) {
			dicPath = '/ecp/resources/css/default/images/';
			$('#addgoodform').dicValid({subBtn : $('#btnSave')});
			
			 // 设置上传
    $("#file_upload").uploadify({
        'auto'     : true,
        'multi'    : true,
        'swf'      : '/ecp/resources/flash/uploadify.swf',
        'uploader' : '/ecp/backstage/test/upload.do',
        'method'   : 'post',
        'formData' : {'someKey' : 'someValue','someOtherKey' : 1},
        'buttonText' : '添加商品图片',
        'fileTypeDesc' : 'image Files',
        'fileTypeExts' : '*.gif; *.png; *.jpg',
        'fileSizeLimit' : '10MB',
        'height' : 20,
        'width' : 80,
        'removeTimeout' : 1,
        'onUploadSuccess' : function(file, data, response) {
          // var obj =  eval("("+data+")"); 
          var obj =$.parseJSON(data);
          
           if(obj.error==0){
             $("#imgsTd").prepend("<div><a style='background-color:red'  ondblclick='javascript:$(this).parent().remove();'>"+file.name+"</a><input name='imgs' type='hidden'   value='"+obj.url+"'></div>"); 
           }else{
              alert(obj.msg);
           }
        },
        'onCancel' : function(file) {
             
        } 
        });
			
			
		});
		
		function save(){
		editor.sync();
		var param = $("#addgoodform").serialize();
		  $.ajax({
		   type: "POST",
		   url: "/ecp/backstage/goods/addGoods.do",
		   data: param,
		   success: function(msg){
		    eval(msg);
		    if(msg.returnCode==0){
		      top.$.dicBox({
		        style : 1,
				content : msg.msg//消息内容
				});
				}else{
				   top.$.dicBox({
		        style : 3,
				content : msg.msg//消息内容 
				});
				}
		   }
		});
		}
	</script>
	
	
	<script charset="utf-8" src="/ecp/editor/kindeditor-min.js"></script>
    <script charset="utf-8" src="/ecp/editor/lang/zh_CN.js"></script>
	<script>
	        KindEditor.ready(function(K) {
	            window.editor =  K.create('#editor_id', {
                uploadJson : '/ecp/backstage/goods/html/upload.do',
                fileManagerJson : '/ecp/backstage/goods/html/fileManager.do',
                allowFileManager : true
             });
	                //   /ecp/editor/jsp/upload_json.jsp
	        });
	</script>
  </head>
  
  <body>
      <myutil:munuPaht menueId='${param.menuId}' optName="新增商品"/>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="ico21">
					&nbsp;
				</td>
				<td class="tb">
					新增商品
				</td>
				<td class="ico4">
					&nbsp;
				</td>
			</tr>
		</table>
		<table class="formTable " width="100%" border="0" cellpadding="0" cellspacing="0">
		   <tbody>
		    <tr>
		      <th width="15%">
		                添加商品LOGO图片：
		      </th>
		      <td colspan="3">
		      <input id="file_upload" type="file" name="file_upload" ></td>
		    </tr>
		   </tbody>
		</table> 
		<form id="addgoodform">
        <table width="100%" border="0" cellpadding="0" cellspacing="0"
				class="formTable ">
				<tbody>
				    <tr>
						<th width="15%">
							商品名称：
						</th>
						<td width="35%">
							 <input type="text" class="input120" vtype = "empty" name="name" />
						</td>
						<th width="15%">
						         商品标题：
						</th>
						<td width="35%">
						   <input type="text" class="input120" vtype = "empty" name="title"   />
						</td>
					</tr>
					<tr>
						<th width="15%">
							商品价格：
						</th>
						<td width="35%">
							 <input type="text" class="input120" name="price" vtype = "pinteger,empty" />
						</td>
						<th width="15%">
						         商品市场价格：
						</th>
						<td width="35%">
						   <input type="text" class="input120" name="mPrice"  vtype = "pinteger,empty"  />
						</td>
					</tr>
					<tr>
						<th width="15%">
							会员价格：
						</th>
						<td width="35%">
							 <input type="text" class="input120" name="vipPrice" vtype = "pinteger,empty"  />
						</td>
						<th width="15%">
						         商品属性： 
						</th>
						<td width="35%">
						   <input type="text" class="input120" name="attribute" vtype = "empty"  />
						</td>
					</tr>
					<tr>
						<th width="15%">
							商品LOGO：
						</th>
						<td width="35%" id="imgsTd">
						    
						</td>
						<th width="15%">
							商品类别：
						</th>
						<td width="35%">
							  <select name = "typeId" size = "1" class = "input120" vtype = "pinteger,empty">
                                <option value="">--请选择--</option>
                                <c:forEach items="${list}" var="goodtype">
                                   <option value="${goodtype['id']}">${goodtype['name']}</option>
                                </c:forEach>
                            </select>
						</td>
					</tr>
					<tr>
						<th width="15%">
							商品库存：
						</th>
						<td width="35%">
							 <input type="text" class="input120" name="num" vtype = "pinteger,empty" />
						</td>
						<th width="15%">
						         商品积分：
						</th>
						<td width="35%">
						   <input type="text" class="input120" name="point"  vtype = "pinteger,empty"  />
						</td>
					</tr>
					<tr>
						<th width="15%">
							商品颜色规格：
						</th>
						<td width="35%">
							 <input type="text" class="input120" name="colors" vtype = "empty" />
						</td>
						<th width="15%">
						         商品尺码规格：
						</th>
						<td width="35%">
						   <input type="text" class="input120" name="sizes"  vtype = "empty"  />
						</td>
					</tr>
					<tr>
						<th width="15%">
							是否推荐商品：
						</th>
						<td width="35%">
							是：<input type="radio"  name="isHot" value="1"  />
							否：<input type="radio" checked="checked"   name="isHot" value="0"  />
						</td>
						<th width="15%">
							是否广告商品：
						</th>
						<td width="35%">
							是：<input type="radio"   name="isAd" value="1"  />
							否: <input type="radio" checked="checked"  name="isAd" value="0"  />
						</td>
					</tr>
					<tr>
						<th width="15%">
							商品描述：
						</th>
						<td width="85%" colspan="3">
							<textarea id="editor_id" rows="25" cols="120" name="desc"></textarea>
						</td>
					</tr>
				</tbody>
			</table>
			</form>
			<table width="100%" border="0" cellspacing="0" cellpadding="0"
				class="mT5">
				<tr>
					<td height="30" align="center">
					   
						<input name="btnSave" id="btnSave" type="button" class="btn1" value="提交"
							onClick="save();">
						<input type="button" value="返回" class="btn1" onclick="history.go(-1);"/>
					</td>
				</tr>
			</table>
      
  </body>
</html>